﻿
/*============== simpleIRC - http://matthias.van-eeghem.com/ ==============*
 *                                                                         *
 *  File: QuickConnect.cs                                                          *
 *  Project: QuickConnect                                                     *
 *  Author(s): Matthias Van Eeghem <matthias@van-eeghem.com>               *
 *                                                                         *
 * ========================================================================*
 *                                                                         *
 *  This program is free software: you can redistribute it and/or modify   *
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation, either version 3 of the License, or      *
 *  (at your option) any later version.                                    *
 *                                                                         *
 *  This program is distributed in the hope that it will be useful,        *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 *                                                                         *
===========================================================================*/

using System;
using System.Windows.Threading;

namespace simpleIRC.UI
{
    class QuickConnect : AbstractClass
    {
        UserInterface UI = null;

        /// <summary>
        /// Called when the Plugin gets loaded
        /// </summary>

        public override void OnPluginLoad()
        {
            // Create a new Server object and window and connect to it!
            UI = new UserInterface(MainWindow);
            Server NewServer = new Server("irc.gtanet.com", 6667, "Matthias|simpleIRC", "Matthias", "Matthias|sIRC", "Using simpleIRC");

            MainWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { new ServerWindow("irc.gtanet.com", 0, MainWindow); }));
            NewServer.Connect();
        }

        /// <summary>
        /// Called when the server is done outputting the MOTD
        /// </summary>
        /// <param name="serverIndex">The server index</param>
        /// <param name="message">The message</param>

        public override void OnMotdEnd(int serverIndex, string message)
        {
            // We wait to join a channel after we've done connecting.
            // If the server index is equal to zero, it's the server we just connected to
            if(serverIndex == 0)
            {
                Channel Channel = new Channel(0, "#Matthias.dev", "");
                Channel.Join();

                MainWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { new ChannelWindow("#Matthias.dev", 0, 0, MainWindow); }));
            }
        }
    }
}
